Repository navigation
fix: report NEXT VALUE FOR and s.NEXTVAL as possible data changes - #2934
Open
tanjiroK-coder wants to merge 1 commit into
Open
tanjiroK-coder wants to merge 1 commit into
tanjiroK-coder wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
StatementFeatureVisitorsends everyFunctionthrough the pure-function check, soSELECT nextval('s')comes back withMODIFIES_DATApossible andnextvalunresolved, and the read-only guard in usage.rst (if (connection.isReadOnly() && features.mayModifyData())) rejects it. The other two ways the grammar spells a sequence advance never get there:NEXT VALUE FOR s/NEXTVAL FOR s(SQL Server, H2, DB2, HSQLDB) parse to aNextValExpression, Oracle'ss.NEXTVALis kept as aColumnnamednextval(the@todoinColumn()), andFeatureExpressionVisitoroverrides neither. SoSELECT NEXT VALUE FOR s,SELECT s.NEXTVAL FROM dualand the same expressions in aWHEREclause or a subquery reportmayModifyData() == falsewith no unresolved reference and pass the guard, although each one advances the sequence just likenextval('s'), and a rollback does not undo that. I found it while comparing the function form ofnextvalwith the other sequence syntaxes the parser accepts. Both nodes now go throughanalyseFunction("nextval"), so they report the same possibleMODIFIES_DATA/MODIFIES_SCHEMAand unresolvednextvalas the function form, and a caller's pure-function predicate treats all three alike; an unqualifiednextvalcolumn andt.currvalare unchanged. Six parameterizedStatementFeatureVisitorTestcases fail before and pass after. spotless, checkstyle, PMD, SpotBugs, the grammar ambiguity check and the test suite pass, except for 35 Mockito and temp-dir test failures that fail the same way on master on my Windows machine.